package com.manlitech.manlichat.base.redis.scenes.pubsub;

import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shensg
 */
@Data
@Component
public class RedisMessageSubscriber implements MessageListener {

    Logger logger = LoggerFactory.getLogger(getClass());

    private List<String> messageList = new ArrayList<>();

    public RedisMessageSubscriber(List<String> messageList) {
    }

    @Override
    public void onMessage(Message message, byte[] pattern) {
        logger.info("[pattern:" + new String(pattern) + ",message:" + message.toString() + "]");
        messageList.add(message.toString());
    }
}

